﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using qlHieuThuocDongY.DataAccess;

namespace qlHieuThuocDongY
{
    public partial class frmTimKiemThuocBanRa : Form
    {
        public frmTimKiemThuocBanRa()
        {
            InitializeComponent();
        }
        ConnectData conn = new ConnectData();
        private void frmTimKiemThuocBanRa_Load(object sender, EventArgs e)
        {
            dataGridViewTimKiemThuocBanRa.DataSource = conn.GetDataTable("Select * from BanThuoc");
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            
            if (txtNhapTimKiemThuocBanRa.Text.Length == 0)
                dataGridViewTimKiemThuocBanRa.DataSource = conn.GetDataTable("Select * from BanThuoc");
            else if (rdMaThuoc.Checked)
                    dataGridViewTimKiemThuocBanRa.DataSource = conn.GetDataTable("Select * from BanThuoc where MaThuoc='" + txtNhapTimKiemThuocBanRa.Text + "'");
                else if (rdMaBN.Checked)
                        dataGridViewTimKiemThuocBanRa.DataSource = conn.GetDataTable("Select * from BanThuoc where MaBN='" + txtNhapTimKiemThuocBanRa.Text + "'");
                    else 
                        dataGridViewTimKiemThuocBanRa.DataSource = conn.GetDataTable("Select * from BanThuoc where MaHDBan='" + txtNhapTimKiemThuocBanRa.Text + "'");
        }
    }
}
